package com.fancy.learncenter.adapter;

import android.app.Activity;
import android.util.Log;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.fancy.learncenter.adapter.base.CommonRecycleViewAdapter;
import com.fancy.learncenter.adapter.base.CustomViewHold;
import com.fancy.learncenter.bean.Student;
import com.fancy.teeya.R;
import com.google.zxing.integration.android.IntentIntegrator;

import java.util.ArrayList;

//import com.umeng.soexample.R;

/**
 * Created by Hyy on 2016/9/18.
 */
public class TestAdapter extends CommonRecycleViewAdapter<Student> {
    Activity mContext;

//    int resourceID = R.layout.activity_universal_item;

    public TestAdapter(Activity mContext, int resource, ArrayList<Student> itemDatas) {
        super(mContext, resource, itemDatas);
        this.mContext = mContext;
    }

    // 根据初始化的layout ID，实现内部控件赋值以及功能
    @Override
    public void bindView(CustomViewHold customViewHold, Student item, int position) {
        TextView tv_content = customViewHold.getView(R.id.tv_content);
        tv_content.setText(item.name + "，年龄是：" + item.age);

        RelativeLayout rl = customViewHold.getView(R.id.cardview);
        rl.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

//                showShareDilaog(mContext);
//                //扫描二维码
//                IntentIntegrator integrator = new IntentIntegrator(mContext);
//                integrator.setDesiredBarcodeFormats(IntentIntegrator.ONE_D_CODE_TYPES);
//                integrator.setPrompt("测试");
//                integrator.setCameraId(0);  // Use a specific camera of the device
//                integrator.setBeepEnabled(false);
//                integrator.setBarcodeImageEnabled(true);
//                integrator.initiateScan();

            }
        });
    }

//    /**
//     * 分享
//     *
//     * @param context
//     */
//
//    private void showShareDilaog(Activity context) {
//
//        UMImage image = new UMImage(context, R.mipmap.ic_launcher);//资源文件
//
//        new ShareAction(context).setDisplayList(SHARE_MEDIA.WEIXIN, SHARE_MEDIA.QQ, SHARE_MEDIA.SINA, SHARE_MEDIA.WEIXIN_CIRCLE)
//                .withText("hello")
//                .withMedia(image)
//                .withTargetUrl("http://www.baidu.com") //分享连接
//                .withTitle("来自扫码登录")
//                .setCallback(umShareListener)
//                .open();
//
//
//    }
//
//
//    Toast toast;
//    private UMShareListener umShareListener = new UMShareListener() {
//        @Override
//        public void onResult(SHARE_MEDIA platform) {
//            toast.makeText(mContext, platform + " 分享成功啦", Toast.LENGTH_SHORT).show();
//        }
//
//        @Override
//        public void onError(SHARE_MEDIA platform, Throwable t) {
//            Toast.makeText(mContext, platform + " 分享失败啦", Toast.LENGTH_SHORT).show();
//            if (t != null) {
//                Log.d("throw", "throw:" + t.getMessage());
//            }
//        }
//
//        @Override
//        public void onCancel(SHARE_MEDIA platform) {
//            Toast.makeText(mContext, platform + " 分享取消了", Toast.LENGTH_SHORT).show();
//        }
//    };


}
